home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: time as a seed
- Date: 7 Feb 1996 14:31:12 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4fb97gINNbbu@keats.ugrad.cs.ubc.ca>
- References: <310EEB1E.688A@one.ucdavis.edu>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <310EEB1E.688A@one.ucdavis.edu>,
- Gary Huxel <huxel@one.ucdavis.edu> wrote:
- >I need help with what should be a simple programming problem. I am
- >trying to use time since UTC as a seed for a simulation using Cellular
- >by Dana Eckert. I am doing this on a SUN with Solaris 2.3 using GNU
- >libraries. I have tried the Standard C library approach and the normal
- >GNU method, but these do not seem to work. Any suggestions/
-
- For your purposes, it might be sufficient to do srand(getpid() * time(NULL)).
- You want to include the process ID of your program in the seed, otherwise
- multiple executions of the program launched within the same second of time will
- have identical sequences.
-
- Not that 32-bit seeds are not cryptographically strong, since they give you
- only 2^32 possible sequences---hence if you generate, say, random keys, you
- effectively reduce the space to 2^32. In your simulation this is probably not a
- concern.
- --
-
-